﻿
using _250210作业.BLL;
using MVCProject.UI;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;

namespace _250210作业.API.Controllers
{
    public class RolesController : ApiController
    {
        // GET: api/Roles
        public ResultData<List<RolesDto>> Get()
        {
            ResultData<List<RolesDto>> result = new ResultData<List<RolesDto>>();

            RolesBLL bll = new RolesBLL();
            var roles = bll.Query();

            var list = from role in roles
                       select new RolesDto
                       {
                           RoleID = role.roleID,
                           RoleName = role.roleName,
                           DeptID = role.deptID,
                           DeptName = role.Department.deptName,
                           Remark = role.remark,
                           LastTime = role.lastTime,
                           Type = role.type
                       };
            result.code = 1;
            result.msg = "ok";
            result.data = list.ToList();


            return result;
        }

        // GET: api/Roles/5
        public string Get(int id)
        {
            return "value";
        }

        // POST: api/Roles
        public void Post([FromBody] string value)
        {
        }

        // PUT: api/Roles/5
        public void Put(int id, [FromBody] string value)
        {
        }

        // DELETE: api/Roles/5
        public void Delete(int id)
        {
        }
    }
}
